package com.example.collegevice.mapper;

import com.example.pojo.Admin;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 操作admin相关数据接口
*/
@Mapper
public interface AdminMapper {

    /**
      * 新增
    */
    @Insert("insert into admin(username, password, name,  avatar, role) " +
            "values(#{username}, #{password}, #{name},#{avatar}, #{role})")
    int insert(Admin admin);

    /**
      * 删除
    */
    @Delete("delete from admin where id = #{id}")
    int deleteById(Integer id);

    /**
      * 修改
    */

    @Update("update admin set username=#{username}, password=#{password}, role=#{role}, " +
            "avatar=#{avatar}, name=#{name} " +
            "where id = #{id}")
    int updateById(Admin admin);

    /**
      * 根据ID查询
    */
    @Select("select * from admin where id = #{id}")
    Admin selectById(Integer id);

    /**
      * 查询所有
    */
     @Select("select * from admin")
    List<Admin> selectAll(Admin admin);

    @Select("select * from admin where username = #{username}")
    Admin selectByUsername(String username);

}